using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteECSWeb;

/// <summary>
/// Summary description for RefeshDetect
/// </summary>

namespace SiteECSWeb
{
    public class RefeshDetect : IHttpModule
    {
        public RefeshDetect()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region IHttpModule Members

        public void Dispose()
        {
        }

        public void Init(HttpApplication app)
        {
            //app.AcquireRequestState += new EventHandler(OnAcquireRequestState);
            app.PostAcquireRequestState += new EventHandler(this.app_PostAcquireRequestState);
            //app.Context.Response.Write("jsdflkjsdf");
        }

        void app_PostAcquireRequestState(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            HttpContext context = app.Context;
            if (context.Request.Url.AbsoluteUri.Contains(".aspx"))
            {
                RefreshAction.Check(context);
            }
            
            return;
        }

        private void OnAcquireRequestState(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            HttpContext context = app.Context;

            RefreshAction.Check(context);
            return;
        }

        #endregion
    }
}
